package com.zc.z_test;


import com.zc.utils.RandCodeUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Random;


public class ThreadA extends Thread {
    private volatile int i = 0;
    private volatile boolean flag = true;

    public boolean isFlag() {
        return flag;
    }

    public void setFlag(boolean flag) {
        this.flag = flag;
    }

    public int getI() {
        return i;
    }

    public void setI(int i) {
        this.i = i;
    }

    private Logger logger = LoggerFactory.getLogger(this.getClass());

    @Override
    public void run() {
        Random random = new Random();
        while (flag) {
            logger.debug("这是一个日志测试文件,线程的名字::" + Thread.currentThread().getName() + ",运行时间::" + System.currentTimeMillis() + ",当前循环次数++" + i + ",error::" + RandCodeUtil.randCode(5) + ",订单号::" + RandCodeUtil.getOrderId());
            try {
                Thread.sleep(random.nextInt(10000));
                i++;
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            if (i == 1000) {
                i = 0;
            }
        }
    }
}
